package com.sonicvision.resourcetracker.employee;

import java.io.ByteArrayInputStream;
import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.sonicvision.resourcetracker.exceptions.ServiceException;
import com.sonicvision.resourcetracker.vendor.Vendor;
import com.sonicvision.resourcetracker.vendor.Vendors;
import com.sonicvision.resourcetracker.vendor.VendorsExcelReader;
import com.sonicvision.resourcetracker.vendor.VendorsUpload;

@Controller
public class EmployeeDocumentsController {

	@Autowired
	private EmployeeDocumentsService docService;
	
	@RequestMapping(value = "/adddocument", method = RequestMethod.GET)
	public ModelAndView addEmpDoc() {
		
		//System.out.println("I am inside get");
		ModelAndView modelAndView = new ModelAndView("AddDocument");
		modelAndView.addObject("documentsUpload", new DocumentsUpload());
		modelAndView.setViewName("AddDocument");
		
		return modelAndView;
	}
	
	@RequestMapping(value = "/adddocument", method = RequestMethod.POST)
	public String saveDocument(@ModelAttribute DocumentsUpload documentsUpload)
			throws Exception {
		
		    MultipartFile documentsFile = documentsUpload.getDocumentsFile();
		
			byte[] documentsFileBytes = documentsFile.getBytes();

			ByteArrayInputStream baos = new ByteArrayInputStream(documentsFileBytes);

			
			return "AddDocumentsAcknowledgement";
		}
	
	
}
